<p>By contract, any implementation of the <code>java.util.Iterator.next()</code> method should throw a <code>NoSuchElementException</code> exception
when the iteration has no more elements. Any other behavior when the iteration is done could lead to unexpected behavior for users of this
<code>Iterator</code>.</p>
<h2>Noncompliant Code Example</h2>
<pre>
public class MyIterator implements Iterator&lt;String&gt;{
  ...
  public String next(){
    if(!hasNext()){
      return null;
    }
    ...
  }
}
</pre>
<h2>Compliant Solution</h2>
<pre>
public class MyIterator implements Iterator&lt;String&gt;{
  ...
  public String next(){
    if(!hasNext()){
      throw new NoSuchElementException();
    }
    ...
  }
}
</pre>

